﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using BlankMvc.Dao.Entities.Base;
using FluentNHibernate.Mapping;
using FluentNHibernate.Utils;

namespace BlankMvc.Dao.Entities.Impl {
	public class Post : Entity<int> {
		public virtual bool Important { get; set; }
		public virtual DateTime DateCreation { get; set; }
		public virtual DateTime DateEdit { get; set; }
		public virtual string Text { get; set; }
		public virtual string Description { get; set; }
		public virtual User Ovner { get; set; }
		public virtual List<Comment> Comments { get; set; }

		public Post() {
			Comments = new List<Comment>();
		}
	}

	public class PostMapping : ClassMap<Post> {
		public PostMapping() {
			Table("Posts");
			Id(x => x.Id);
			Map(x => x.Important);
			Map(x => x.DateCreation);
			Map(x => x.DateEdit);
			Map(x => x.Text).Length(8000).Not.Nullable();
			Map(x => x.Description).Length(3000).Not.Nullable();
			HasMany(x => x.Comments);
		}
	}
}
